// uiDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ui.h"
#include "uiDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUiDlg dialog

CUiDlg::CUiDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CUiDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUiDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CUiDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUiDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CUiDlg, CDialog)
	//{{AFX_MSG_MAP(CUiDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_HOME, OnHome)
	ON_BN_CLICKED(IDC_HELP, OnHelp)
	ON_BN_CLICKED(IDC_ON, OnOn)
	ON_BN_CLICKED(IDC_EDITSITES, OnEditsites)
	ON_BN_CLICKED(IDC_CHANGE, OnChange)
	ON_BN_CLICKED(IDC_EDITPROXY, OnEditproxy)
	ON_BN_CLICKED(IDC_OFF, OnOff)
	ON_BN_CLICKED(IDC_UPDATEPROXY, OnUpdateproxy)
	ON_BN_CLICKED(IDC_HELPME, OnHelpme)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUiDlg message handlers
char path[1024]={0};
BOOL CUiDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	DWORD len = GetModuleFileNameA(GetModuleHandle(NULL),path,1024);
	path[len-6] = 0;
//	printf("%s\n",path); 
//	MessageBox(path,"b",MB_OK);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CUiDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

HCURSOR CUiDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CUiDlg::OnHome() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","http://sites.google.com/site/wangyedaili/", NULL, path, SW_SHOWNORMAL);
}

void CUiDlg::OnHelp() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","http://sites.google.com/site/wangyedaili/", NULL, path, SW_SHOWNORMAL);
}

void CUiDlg::OnOn() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","check.exe", "on", path, SW_SHOWNORMAL);
}

void CUiDlg::OnEditsites() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","sites.txt", NULL, path, SW_SHOWNORMAL);
}

void CUiDlg::OnAddsite() 
{
	// TODO: Add your control notification handler code here
	
}

void CUiDlg::OnChange() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","check.exe", "change", path, SW_SHOWNORMAL);
}

void CUiDlg::OnEditproxy() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","proxys.txt", NULL, path, SW_SHOWNORMAL);
}

void CUiDlg::OnOff() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","check.exe", "off", path, SW_SHOWNORMAL);
}

void CUiDlg::OnUpdateproxy() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL, "open","check.exe", "updateproxys", path, SW_SHOWNORMAL);
}

void CUiDlg::OnHelpme() 
{
	// TODO: Add your control notification handler code here
	
}
